// this file was added from scratch to the project by Josh Latvatalo
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
#include "Date.h"

bool Date::date_valid(int y, int m, int d)
{
	if(y<1753)
	{
		return false;
	}
	if(m<1||m>12)
	{
		return false;
	}
	if(d<1||d>31)
	{
		return false;
	}
	if((m==4 || m==6 || m==9 || m==11)&& d>30)
	{
		return false;
	}	
	if(m==2 && d>28)
	{	
		if(d==29&&y%100==0&&y%400!=0)
			return false;
		else if(d>29)
			return false;
			
	}
	return true;
}
Date::Date(int y, int m, int d)
{
	if(date_valid(y,m,d))
	{
		year = y;
		month = m;
		day = d;
	}
	else
		cerr<< "ERROR: Invalid date entry \n";
}

Date::Date(){}

string Date::display_date(){
	ostringstream oss;
	oss<< "Year: " << year << " Month: " << month << " Day: " << day << "\n";
	return oss.str();
}

